﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace BAL
{
    public class Mentors
    {
        public static string con = BAL.conn.connectionString;

        public static int CreateMentor(int IDMentor, int IDUser)
        {
            SqlParameter[] arrParam = new SqlParameter[2];
            arrParam[0] = new SqlParameter("@IDMentor", SqlDbType.Int);
            arrParam[0].Value = IDMentor;
            arrParam[1] = new SqlParameter("@IDUser", SqlDbType.Int);
            arrParam[1].Value = IDUser;
            int UserId = Convert.ToInt32(VocationSpace.DAL.SqlHelper.ExecuteNonQuery(con, CommandType.StoredProcedure, "VS_CreateMentor", arrParam));
            return UserId;
        }
        public static DataSet GetAllMentorsByUser(int Iduser)
        {
            SqlParameter[] arrParam = new SqlParameter[1];
            arrParam[0] = new SqlParameter("@iduser", SqlDbType.Int);
            arrParam[0].Value = Iduser;
            DataSet ds = VocationSpace.DAL.SqlHelper.ExecuteDataset(con, CommandType.StoredProcedure, "VS_GetMentorsByUser", arrParam);
            return ds;
        }
        public static int InsetMentorsQuestion(int IDUserMentor, string question)
        {
            SqlParameter[] arrParam = new SqlParameter[2];
            arrParam[0] = new SqlParameter("@IDUserMentor", SqlDbType.Int);
            arrParam[0].Value = IDUserMentor;
            arrParam[1] = new SqlParameter("@question", SqlDbType.VarChar);
            arrParam[1].Value = question;

            int IdMentorQuestion = Convert.ToInt32(VocationSpace.DAL.SqlHelper.ExecuteNonQuery(con, CommandType.StoredProcedure, "VS_InsertMentorQuestion", arrParam));
            return IdMentorQuestion;
        }
        public static void InsertMentorAnswer(int IdQuestion, string ans)
        {
            SqlParameter[] arrParam = new SqlParameter[2];
            arrParam[0] = new SqlParameter("@idQuestion", SqlDbType.Int);
            arrParam[0].Value = IdQuestion;
            arrParam[1] = new SqlParameter("@answer", SqlDbType.VarChar);
            arrParam[1].Value = ans;

            VocationSpace.DAL.SqlHelper.ExecuteNonQuery(con, CommandType.StoredProcedure, "VS_InsertMentorAnswer", arrParam);           
        }


    }
}
